﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WMS.FC.Domain.PersistenceObject.Business;
using WMS.FC.Infrastructure.Common;

namespace WMS.FC.Infrastructure.POConfig.Business
{
    public class StationRouteConfig : POBaseConfig<StationRoutePO>
    {
        public override void InitializeData(EntityTypeBuilder<StationRoutePO> builder)
        {
        }

        public override void MapColumn(EntityTypeBuilder<StationRoutePO> builder, ref int index)
        {
            builder.HasComment("站台路径表");
            builder.Property(entity => entity.LineCode).ConfigColumn("LINE_CODE", "产线编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.StationCode).ConfigColumn("STATION_CODE", "站台编码", 50).HasColumnOrder(index++);
            builder.Property(entity => entity.EquipmentCode).ConfigColumn("EQUIPMENT_CODE", "设备编码", 50).HasColumnOrder(index++);
            builder.Property(entity => entity.ToStationCode).ConfigColumn("TO_STATION_CODE", "目标站台编码", 50).HasColumnOrder(index++);
            builder.Property(entity => entity.ToEquipmentCode).ConfigColumn("TO_EQUIPMENT_CODE", "目标设备编码", 50).HasColumnOrder(index++);
            builder.Property(entity => entity.WarehouseCode).ConfigColumn("WAREHOUSE_CODE", "仓库编码", 50, true).HasColumnOrder(index++);
        }

        public override void MapIndex(EntityTypeBuilder<StationRoutePO> builder)
        {
            builder.HasIndex(entity => new { entity.StationCode, entity.WarehouseCode, entity.LineCode }).HasDatabaseName($"IDX_{TableName}_1");
            builder.HasIndex(entity => new { entity.EquipmentCode, entity.WarehouseCode, entity.LineCode }).HasDatabaseName($"IDX_{TableName}_2");
        }
    }
}
